package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsGoodsProductMapper;
import com.qf.pojo.DtsGoodsProduct;
import com.qf.service.DtsGoodsProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DtsGoodsProductServiceImpl implements DtsGoodsProductService {
    @Autowired
    DtsGoodsProductMapper productMapper;
    @Override
    public void insert(DtsGoodsProduct product) {
        product.setAddTime(new Date());
        product.setDeleted(false);
        product.setUpdateTime(new Date());
        productMapper.insert(product);

    }

    @Override
    public List<DtsGoodsProduct> select(Integer goodsId) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("goods_id",goodsId);
        List list = productMapper.selectList(wrapper);
        return list;
    }

    @Override
    public void update(DtsGoodsProduct[] products) {

        for (DtsGoodsProduct product : products) {
            productMapper.updateById(product);
        }
    }
}
